#include "stdafx.h"
#include "wf_zoomauto.h"


/**
 * Constructor.
 *
 * @param keepAspectRatio true: keep same zoom value for x/y.
 *                        false: adjust both x and y individually
 */
WF_ZoomAuto::WF_ZoomAuto(PF_Container& container,
                                     PF_GraphicView& graphicView,
                                     bool keepAspectRatio)
        :PF_ActionInterface("Auto zoom", container, graphicView) {

    this->keepAspectRatio = keepAspectRatio;
}


QAction* WF_ZoomAuto::createGUIAction(LX_Define::ActionType /*type*/, QObject* /*parent*/) {
	// tr("Auto Zoom")
	QAction* action = new QAction(tr("&Auto Zoom"), NULL);
#if QT_VERSION >= 0x040600
        action->setIcon(QIcon::fromTheme("zoom-fit-best", QIcon(":/actions/zoomauto.png")));
#else
        action->setIcon(QIcon(":/actions/zoomauto.png"));
#endif
        //action->zetStatusTip(tr("Zooms automatic"));

	return action;
}


void WF_ZoomAuto::init(int status) {
    PF_ActionInterface::init(status);
    trigger();
}



void WF_ZoomAuto::trigger() {
    graphicView->zoomAuto(false, keepAspectRatio);
    finish();
}

// EOF
